package study04;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class Java12_map_itr {
    public static void main(String[] args) throws Exception {
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        map.put("zs", 1);
        map.put("ls", 2);
        map.put("ww", 3);

        Set<String> keys = map.keySet();
//
//        for (String key : keys) {
//            System.out.println(map.get(key));
//        }

//        迭代器
        Iterator<String> iterator = keys.iterator();
//        hasNext 判断是否有下一条数据
        while (iterator.hasNext()) {
            String key = iterator.next();
//            获取下一条数据
            if ("ls".equals(key)) {
//                只能删除当前的
                iterator.remove();
            }
            System.out.println(map.get(key));
        }

        System.out.println(iterator);
    }
}
